import pymysql
from fastapi import FastAPI,HTTPException,Form
app=FastAPI()
db={
    "host":"localhost",
    "user":"root",
    "password":"123456",
    "database":"2304a",
    "charset":"utf8"
}
@app.post('/bwqq')
def bwqq(
    #attendance_id:str=Form(...),
    employee_name:str=Form(...),
    attendance_date:str=Form(...),
    #attendance_status:str=Form(...)
):
    try:
        con=pymysql.connect(**db)
        cur=con.cursor()
        #cur.execute('insert into attendance(attendance_id,employee_name,attendance_date,attendance_status) values(%s,%s,%s,%s) ',(attendance_id,employee_name,attendance_date,attendance_status))
        cur.execute('select * from attendance  where employee_name=%s or attendance_date=%s',( employee_name,attendance_date))
        fis=cur.fetchone()
        if fis:         
            return {
                        "a":fis[0],
                        "b":fis[1],
                        "c":fis[2],
                        "d":fis[3]
                }
    finally:
        con.close()
        cur.close()


        
   
    